package com.wn32.main.demo7;

public class Main8 {
    public static void main(String[] args) throws InterruptedException {
        Shop shop = new Shop();
        Runnable r=() ->{
            shop.buyOne();
        };
        Thread th1=new Thread(r,"线程A");//可以给线程起名字
        Thread th2=new Thread(r,"线程B");
        th1.start();
        //Thread.sleep(2000);//改变线程开启时间,使线程安全
        th2.start();
    }
}
